define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	require("$UI/system/lib/cordova/cordova");
	require("cordova!com.phonegap.plugins.videoplayer");

	var Model = function() {
		this.callParent();
		this.url = "http://yun.jiawoltd.com";
		//this.url = "http://127.0.0.1:8888";
	};

	Model.prototype.media1Click = function(event) {
		var url = event.bindingContext.$object.val('hls');
		if (!url) {
			justep.Util.hint("播放地址出错", {
				type : "danger"
			});
			return false;
		}
		cordova.plugins.videoPlayer.play(url);
	};

	Model.prototype.modelLoad = function(event) {
	};

	Model.prototype.scrollView1PullDown = function(event) {
		var cameraData = this.comp("cameraData");
		var userId = localStorage.getItem("USER_ID");
		var url = this.url +"/mobile/getCameras/"+userId;
		$.ajax({
			cache : false,
			type : "GET",
			timeout : 20000, // 超时时间设置，单位毫秒
			url : url,
			data : {},
			async : false,
			error : function(request) {
			},
			success : function(data) {
				cameraData.clear();
				cameraData.loadData(data);
			}
		});
		
	};

	Model.prototype.cameraDataCustomRefresh = function(event) {
		var userId = localStorage.getItem("USER_ID");
		var url = this.url + "/mobile/getCameras/"+userId;
		$.ajax({
			cache : false,
			type : "GET",
			timeout : 20000, // 超时时间设置，单位毫秒
			url : url,
			data : {},
			async : false,
			error : function(request) {
			},
			success : function(data) {
				event.source.loadData(data);
			}
		});
		
	};

	return Model;
});